package com.ceba.test.modules.storage.service;

import java.util.List;
import java.util.Map;

import org.json.JSONObject;

import com.ceba.test.modules.storage.dao.GStorageAddressDao;
import com.ceba.test.modules.storage.entity.GStorageAddress;

/**
 * 文件存储地址表操作层
 * @author Administrator
 *
 */
public class GStorageAddressService {
	private GStorageAddressDao gStorageAddressDao;
	
	/**
	 * 查询
	 * @param id 关键字
	 * @return
	 */
	public GStorageAddress sreach(String id){
		return gStorageAddressDao.sreach(id);
	}
	
	/**
	 * 查詢目錄是否被使用過
	 * @param path
	 * @return
	 */
	public long sreachPath(String id,String path,String fileName){
		return gStorageAddressDao.sreachPath(id,path,fileName);
	}

	
	/**
	 * @param gStorageAddress 对象
	 * 编辑
	 * @return
	 */
	public boolean edit(GStorageAddress gStorageAddress){
		return gStorageAddressDao.edit(gStorageAddress);
	}
	/**
	 * 编辑
	 * @param gStorageAddress 对象
	 * @return
	 */
	public boolean editAll(GStorageAddress gStorageAddress){
		return gStorageAddressDao.editAll(gStorageAddress);
	}

	/**
	 * 添加
	 * @param gStorageAddress 对象
	 * @return
	 */
	public boolean add(GStorageAddress gStorageAddress){
		return gStorageAddressDao.add(gStorageAddress);
	}


	public GStorageAddressDao getgStorageAddressDao() {
		return gStorageAddressDao;
	}


	public void setgStorageAddressDao(GStorageAddressDao gStorageAddressDao) {
		this.gStorageAddressDao = gStorageAddressDao;
	}


	public JSONObject list(GStorageAddress gStorageAddress, Map<String, Object> dic) {
		return gStorageAddressDao.list(gStorageAddress,dic);
	}
	public List<GStorageAddress> sreachAll() {
		return gStorageAddressDao.sreachAll();
	}

	/**
	 * 删除
	 * @param id
	 * @return
	 */
	public boolean delete(String id) {
		return gStorageAddressDao.delete(id);
	}


	public long totalCount() {
		return gStorageAddressDao.totalCount();
	}
	
	
	public void editCopyFlag(String id, String code) {
		gStorageAddressDao.editCopyFlag(id, code);
	}
	public void editStatus(String id, String code) {
		gStorageAddressDao.editStatus(id, code);
	}
	
	
	
	/**
	 * 随机附件
	 * 
	 * select (select VIRTUAL_PATH from ids_g_file where ID=gf.FILE_ID) as VIRTUAL_PATH from IDS_WF_REPORT p,IDS_WF_USER_INSTANCE i,ids_wf_user_file f,IDS_WF_USER_FILE_ATTACH a,ids_g_user_file gf  
				where p.STORAGE_ADDRESS_ID = '55555555555555555555555555555555' and p.ID = i.REPORT_ID and i.ID=f.WF_USER_INSTANCE_ID and f.ID =a.ATTACH_FILE_ID and a.USER_FILE_ID=gf.ID order by rand() limit 10
	 * 
	 * @param id
	 * @return
	 */
	public List<String> randAttachFile(String id) {
		return gStorageAddressDao.randAttachFile(id);
	}
	/**
	 * 随机签名文件
	 * select  (select VIRTUAL_PATH from ids_g_file where ID=r.FILE_ID) as VIRTUAL_PATH from ids_wf_sign_record r,ids_wf_report p where r.REPORT_ID=p.ID and p.STORAGE_ADDRESS_ID = '55555555555555555555555555555555' order by rand() limit 20
	 * @param id
	 * @return
	 */
	public List<String> randSignFile(String id) {
		return gStorageAddressDao.randSignFile(id);
	}
	/**
	 * 随机主文件
	 * select (select VIRTUAL_PATH from ids_g_file where ID=ORIENT_FILE_ID) as VIRTUAL_PATH from ids_wf_report where STORAGE_ADDRESS_ID = '55555555555555555555555555555555' order by ra  nd() limit 10
	 * @param id 
	 * @return
	 */
	public List<String> randMailFile(String id) {
		return gStorageAddressDao.randMailFile(id);
	}
	/**
	 * 随机签章
	 * select FILE_PATH from ids_g_stamp where STORAGE_ADDRESS_ID ='55555555555555555555555555555555' order by rand() limit 10
	 * @param id
	 * @return
	 */
	public List<String> randStampFile(String id) {
		return gStorageAddressDao.randStampFile(id);
	}
	/**
	 * 随机模板文件
	 * select VIRTUAL_PATH from ids_g_templates_word  order by rand() limit 10
	 * @param id
	 * @return
	 */
	public List<String> randTemplatesFile(String id) {
		return gStorageAddressDao.randTemplatesFile(id);
	}

	/**
	 * 更新路径
	 * @param id
	 * @param value
	 */
	public void updatePath(String id,String value){
		gStorageAddressDao.updatePath(id,value);
	}

	/**
	 * 查询出已拷贝状态的存储地址
	 * @return
	 */
	public GStorageAddress searchCopiedAddress() {
		return gStorageAddressDao.searchCopiedAddress();
	}
}
